package com.lj.back.manage.scaffold.common.DTO;

import com.lj.back.manage.scaffold.common.annotation.valid.EnumCheck;
import com.lj.back.manage.scaffold.common.constant.Constant;
import com.lj.back.manage.scaffold.common.enums.OrderTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * 分页查询对象
 * @author lv
 * @version 1.0.0
 */
@Data
@Validated
@ApiModel("分页查询对象")
public class PageQuery {

    @ApiModelProperty(value = "当前页码",example = "1",required = true)
    @NotNull(message = "{list.page.current}")
    @Min(value = 1,message = "{list.page.current.min}")
    private Integer current;

    @ApiModelProperty(value = "每页显示数量",example = "10",required = true)
    @NotNull(message = "{list.page.size}")
    @Min(value = 1,message = "{list.page.size.min}")
    @Max(value = 100,message = "{list.page.size.max}")
    private Integer size;

    @ApiModelProperty(value = "搜索关键字",example = "deleteToken")
    private String key;

    @ApiModelProperty(value = "排序方式",example = "1")
    @EnumCheck(enumClass = OrderTypeEnum.class)
    private String orderType = Constant.DEFAULT_PAGE_ORDER_TYPE;

    @ApiModelProperty(value = "排序字段",example = "name")
    private String orderField = Constant.DEFAULT_PAGE_ORDER_FIELD;
}
